<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="cn.edu.nju.ws.sview.Config,java.util.Enumeration,cn.edu.nju.ws.sview.views.Entity,cn.edu.nju.ws.sview.views.data.EntityBrowsing,cn.edu.nju.ws.sview.cache.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SView browsing</title>
<link rel="stylesheet" type="text/css" href="/sview/css/layout.css" />
</head>
<body>
<%
	String lang = request.getParameter("lang");
	if(lang==null)
		lang = "en";
%>
<div class="load-data2"></div>
<%
	String uri = request.getParameter("query") ;
   boolean flag = true;
   if(uri==null||uri.trim().equals("")){
	   flag = false;
   }else{
	   uri = uri.trim();
	   flag = EntityBrowsing.hasRDFDescription(uri) ;
   }
 
   if(!flag){
	 /* start:由于DBpedia等网站会被封掉，因此使用falcons数据集作为后备*/
       flag = EntityBrowsing.getReserveRDFDescription(uri);
      /* end:由于DBpedia等网站会被封掉，因此使用falcons数据集作为后备*/   
   }
   
   if(!flag){
	   if(uri==null)
	   		uri="";
	   String redirect = "nodes.jsp?u="+uri;
	   if(lang.equals("zh"))
		   redirect = redirect+"&lang=zh" ;
	   response.sendRedirect(redirect);
   }else{
		String idStr = Entity.URI_ENTITY_Str;
		try{
		  int id = URIIDCache.getInstance().getURIID(uri,true);
		  idStr+=id;
		}catch(Throwable e){
	e.printStackTrace();
		}
		String redirect = "../entity/"+idStr;
		if(lang.equals("zh"))
	redirect = redirect+"?lang=zh" ;
		 response.sendRedirect(redirect); 
   }
%>
<jsp:include page="/vfooter.jsp"></jsp:include>
</body>
</html>